package com.mmall.common;

import lombok.Getter;
import lombok.Setter;

public class Const {
    public static final String salt = "dsadklsaldjsald";
    public static final String CURRENT_USER = "CURRENT_USER";

    public enum Role {
        ROLE_CUSTOMER(0, "ROLE_CUSTOMER"),
        ROLE_ADMIN(1, "ROLE_ADMIN");
        private int code;
        private String msg;

        Role(int code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public int getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }
    }

    public interface CheckType{
        String USER_NAME = "username";
        String USER_EMAIL = "email";
    }

    public interface  ProductStatus {
        int ON_SALE = 1;
    }

    public static final String IMAGES_PREFIX = "IMAGES_PREFIX";

    public interface ProductOrder{
         String ORDER_BY_PRICE_ASC = "price_asc";
         String ORDER_BY_PRICE_DESC = "price_desc";
         String SPLITE = "_";
    }

    public interface Cart{
        int CHECKED = 1;//购物车选中
        int UN_CHECKED = 0;//购物车不支持

        String LIMIT_NUM_FAIL = "LIMIT_NUM_FAIL";
        String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
    }

    public enum PaymentTypeEnum{

        ONLINE_PAY(0,"ONLINE_PAY");

        private int code;
        private String desc;

        PaymentTypeEnum(int code,String desc){
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static PaymentTypeEnum valueOf(int code){
            for(PaymentTypeEnum paymentTypeEnum:values()){
                if(paymentTypeEnum.code==code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }


    public enum OrderStatusEnum{
        CANCELED(0,"已取消"),
        NO_PAYED(10,"未支付"),
        PAYED(20,"已支付"),
        SHIPPED(40,"已发货"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭");
        private int code;
        private String desc;
        OrderStatusEnum(int code,String desc){
            this.code = code;
            this.desc = desc;
        }

        public OrderStatusEnum valueOf(int code){
            for(OrderStatusEnum orderStatusEnum:values()){
                if(orderStatusEnum.getCode()==code){
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }


//    public enum  ProductStatusEnum{
//        int code;
//        String desc;
//        ProductStatusEnum
//    }
}
